package com.niit.order;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author yaojianfeng
 */
@MapperScan("com.niit.order.mapper")
@SpringBootApplication
//@EnableCircuitBreaker // 启用断路器功能
@EnableHystrix //启用Hystrix能力 包括断路器功能
//添加过滤器组件的包扫描,否则加载不到过滤器
@ServletComponentScan(basePackages = {"com.niit.order.filter"})
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    /**
     * 注册RestTemplate 并添加负载均衡能力注解
     *
     * @return RestTemplate
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


}